package gs.sr.tkfx.util;

import gs.sr.tkfx.param.Resp;
import gs.sr.tkfx.param.TopParameters;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;

public class RespUtils {
	/**
	 * convert http request to internal bean
	 * 
	 * @author <a href="mailto:zhenbei@taobao.com">震北</a>
	 * @since 2012-1-18 下午2:31:39
	 * 
	 * @param parameterMap
	 * @return
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 */
	public static final Resp parseResp(Map<String, String[]> parameterMap)
			throws IllegalAccessException, InvocationTargetException {
		Resp resp = new Resp();
		BeanUtils.populate(resp, parameterMap);
		return resp;
	}

	/**
	 * convert decoded TopParameters to internal bean
	 * 
	 * @author <a href="mailto:zhenbei@taobao.com">震北</a>
	 * @since 2012-1-18 下午6:04:33
	 * 
	 * @param m
	 * @return
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 */
	public static final TopParameters parseTopParameters(Map<String, String> m)
			throws IllegalAccessException, InvocationTargetException {
		TopParameters p = new TopParameters();
		BeanUtils.populate(p, m);
		return p;
	}

}
